{extend name="common@admin_base" /}

{block name="body"}
<form method="post" class="layui-form" lay-filter="config_form">
    <div class="layui-form-item">
        <label class="layui-form-label">关键词<span style="color: red">*</span></label>
        <div class="layui-input-block">
            <input name="key" required autocomplete="off" placeholder="请输入关键词" class="layui-input" type="text">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">对应值<span style="color: red">*</span></label>
        <div class="layui-input-block">
            <input name="value" lay-verify="required" autocomplete="off" placeholder="请输入对应值" class="layui-input" type="text">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">备注<span style="color: red">*</span></label>
        <div class="layui-input-block">
            <textarea name="remark" autocomplete="off" placeholder="请输入备注" class="layui-textarea" type="text"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <input class="layui-btn" id="submit" lay-submit="" lay-filter="config_form" type="submit" value="立即提交"/>
        </div>
    </div>
</form>
{/block}


{block name="head_extends"}
<script type="application/javascript">
    layui.config({
        base: '/static/js/',
    }).extend({
        authtree: '',
    });
    layui.use(['jquery', 'authtree', 'form'], function(){
        form.on('submit(config_form)',function (data) {
            console.log(data.field);
            $.ajax({
                url:'{$_form.admin_config_save}'
                ,data:data.field
                ,method:'post'
                ,success:function (data) {
                    console.log(data);
                    if (typeof data == 'string'){
                        data = JSON.parse(data);
                    }
                    parent.layer.alert(data.info);
                    if (data.msg == 1){
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    }
                }
            });
            return false;
        });
    });
</script>
{/block}